package com.zuqiuzhandui.liveing.net;

import com.zuqiuzhandui.testing.myhelper.BoreConstants;

import rx.Observable;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

/**
 * Created by yq on 2016-10-11.
 */

public class ObservableDecorator {
    public static <T> Observable<T> decorate(Observable<T> observable) {
        Observable<T> newObservable;
        if(BoreConstants.isUnitTest) {
            newObservable = observable.subscribeOn(Schedulers.immediate())
                    .observeOn(Schedulers.immediate());
        } else {
            newObservable = observable.subscribeOn(Schedulers.io())
                    .unsubscribeOn(Schedulers.io())
                    .observeOn(AndroidSchedulers.mainThread())
//                    .delay(2, TimeUnit.SECONDS, AndroidSchedulers.mainThread()); // FIXME 模拟延迟,用于观察加载框等效果
            ;
        }
        return newObservable;
    }




}
